/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package crm.salesOrderProcessing.entity;

import crm.clientManagement.entity.AddressEntity;
import frm.billingAndPaymentProcessing.entity.InvoiceEntity;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Temporal;
import scm.inventoryControl.entity.PackingOrderEntity;
import scm.inventoryControl.entity.PickingOrderEntity;
import scm.inventoryControl.entity.ShippingOrderEntity;


@Entity
public class DeliveryOrderEntity implements Serializable {

    private static long serialVersionUID = 1L;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public static void setSerialVersionUID(long aSerialVersionUID) {
        serialVersionUID = aSerialVersionUID;
    }
    @Id
    private Long id;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date generateDate;
    @Temporal(javax.persistence.TemporalType.DATE)
    private Date deliveryDate;
    @ManyToOne
    private SalesOrderEntity parentSalesOrder;
    @OneToMany(cascade = {CascadeType.ALL})
    private List<LineItemEntity> deliveryOrderLineItems;
    @OneToOne(cascade = {CascadeType.ALL}, mappedBy = "deliveryOrder")
    private InvoiceEntity invoice;
    @ManyToOne
    private AddressEntity shippingAddress;
    @ManyToOne
    private AddressEntity billingAddress;
    @OneToOne (cascade ={CascadeType.ALL},mappedBy="deliveryOrder")
    private PickingOrderEntity pickingOrder;
    @OneToOne (cascade ={CascadeType.ALL},mappedBy="deliveryOrder")
    private PackingOrderEntity packingOrder;
    @OneToOne(cascade ={CascadeType.ALL},mappedBy="deliveryOrder")
    private ShippingOrderEntity shippingOrder;

    private boolean isCIAPayment;
    private boolean paymentStatus;
    private boolean isShipped;
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof DeliveryOrderEntity)) {
            return false;
        }
        DeliveryOrderEntity other = (DeliveryOrderEntity) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "sales.entity.DeliveryOrderEntity[ id=" + id + " ]";
    }

    public Date getGenerateDate() {
        return generateDate;
    }

    public void setGenerateDate(Date generateDate) {
        this.generateDate = generateDate;
    }

    public SalesOrderEntity getParentSalesOrder() {
        return parentSalesOrder;
    }

    public void setParentSalesOrder(SalesOrderEntity parentSalesOrder) {
        this.parentSalesOrder = parentSalesOrder;
    }

    public InvoiceEntity getInvoice() {
        return invoice;
    }

    public void setInvoice(InvoiceEntity invoice) {
        this.invoice = invoice;
    }

    public Date getDeliveryDate() {
        return deliveryDate;
    }

    public void setDeliveryDate(Date deliveryDate) {
        this.deliveryDate = deliveryDate;
    }

    public List<LineItemEntity> getLineItems() {
        return getDeliveryOrderLineItems();
    }

    public void setLineItems(List<LineItemEntity> lineItems) {
        this.setDeliveryOrderLineItems(lineItems);
    }

    public boolean isPaymentStatus() {
        return paymentStatus;
    }

    public void setPaymentStatus(boolean paymentStatus) {
        this.paymentStatus = paymentStatus;
    }

    /**
     * @return the shippingAddress
     */
    public AddressEntity getShippingAddress() {
        return shippingAddress;
    }

    /**
     * @param shippingAddress the shippingAddress to set
     */
    public void setShippingAddress(AddressEntity shippingAddress) {
        this.shippingAddress = shippingAddress;
    }

    /**
     * @return the billingAddress
     */
    public AddressEntity getBillingAddress() {
        return billingAddress;
    }

    /**
     * @param billingAddress the billingAddress to set
     */
    public void setBillingAddress(AddressEntity billingAddress) {
        this.billingAddress = billingAddress;
    }

    public List<LineItemEntity> getDeliveryOrderLineItems() {
        return deliveryOrderLineItems;
    }

    public void setDeliveryOrderLineItems(List<LineItemEntity> deliveryOrderLineItems) {
        this.deliveryOrderLineItems = deliveryOrderLineItems;
    }

    public boolean isIsShipped() {
        return isShipped;
    }

    public void setIsShipped(boolean isShipped) {
        this.isShipped = isShipped;
    }


    public PickingOrderEntity getPickingOrder() {
        return pickingOrder;
    }

    public void setPickingOrder(PickingOrderEntity pickingOrder) {
        this.pickingOrder = pickingOrder;
    }

    public PackingOrderEntity getPackingOrder() {
        return packingOrder;
    }

    public void setPackingOrder(PackingOrderEntity packingOrder) {
        this.packingOrder = packingOrder;
    }

    public ShippingOrderEntity getShippingOrder() {
        return shippingOrder;
    }

    public void setShippingOrder(ShippingOrderEntity shippingOrder) {
        this.shippingOrder = shippingOrder;
    }

    public boolean isIsCIAPayment() {
        return isCIAPayment;
    }

    public void setIsCIAPayment(boolean isCIAPayment) {
        this.isCIAPayment = isCIAPayment;
    }


}
